 <script type="text/javascript" src="${pageContext.request.contextPath }/My97DatePicker/WdatePicker.js"></script>   <!--这是我的位置-->
<%@page import="cn.com.gzqd.model.Book"%>
<%@page import="cn.com.gzqd.serviceimpl.BookServiceImpl"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@ page import="cn.com.gzqd.bean.Page"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">

<style type="text/css">
body {}
#ch,#gx{
	display:none;
	background: none repeat scroll 0 0 aliceblue;
    left: 500px;
    position: absolute;
    top: 1000px;
    z-index: 99;
}

</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>心愿单管理</title>

</script>
<script type="text/javascript">
	function num1(s,t){
		document.form1.submit();
		if(t=""){
		}
		else document.form1.submit();
		}
	
</script>


<script type="text/javascript">
	function move()
	{
		var top=document.body.scrollTop | document.documentElement.scrollTop;
		document.getElementById("ch").style.posTop =top+20;
		document.getElementById("gx").style.posTop =top+20;
	}
	window.onscroll=move;
	window.pageYOffset=move;
	window.pageXOffset=move;
</script>

<script>
  function changes1(){ 
     document.getElementById("test1").style.display="none";
 }
</script>
<script>
  function changes2(){  
     document.getElementById("test1").style.display="";
 }
</script>
<script>
  function changes3(){ 
     document.getElementById("text7").style.display="none";
 }
</script>
<script>
  function changes4(){  
     document.getElementById("text7").style.display="";
 }
</script>
<script type="text/javascript">
var testresults;
function isNumber(){
	var str=document.form1.txt5.value;
	var filter=/^[0-9]*[1-9][0-9]*$/;
	if (filter.test(str))
	testresults=true;
else
	{
	alert("请输入数字");
	testresults=false;
	}
return (testresults);
}
</script>
<script type="text/javascript">
var testresults;
function isNumber2(){
	var str=document.form1.txt5.value;
	var filter=/^[0-9]*[1-9][0-9]*$/;
	if (filter.test(str))
	testresults=true;
else
	{
	alert("请输入数字");
	testresults=false;
	}
return (testresults);
}
</script>
</head>
<%
	request.setCharacterEncoding("UTF-8");
%>
<body>
	 
    <div class="jumbotron">
     <nav class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <h2><a> <i class="glyphicon glyphicon-list"></i></a>购置心愿单</h2>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
         <form action="PageServlet" method="post" class="navbar-form navbar-right">
			 <div class="form-group">
			<input type="text" name="xs" placeholder="请输入关键词"  class="form-control">
			 </div>
			 <button type="submit"  class="btn btn-success">
          <span class="glyphicon glyphicon-search"></span> 查询
        </button>
			<button type="button" class="btn btn-success" data-toggle="modal" data-target="#myModal1">
          <span class="glyphicon glyphicon-plus"></span> 添加
        </button>

		</form>
        </div><!--/.navbar-collapse -->
      
      </div>
    </nav>
    
    

	
		<div class="container">

		<table class="table table-striped table-bordered table-hover table-condensed text-center">
			<tr >
				<td><h3>序号</h3></td>
				<td><h3>书名</h3></td>
				<td><h3>作者</h3></td>
				<td><h3>出版社</h3></td>
				<td><h3>数量</h3></td>
				<td><h3>是否已购买</h3></td>
				<td><h3>购买时间</h3></td>
				<td><h3>备注</h3></td>
				<td><h3>操作</h3></td>

			</tr>
			<%
			response.setCharacterEncoding("UTF-8");
			request.setCharacterEncoding("UTF-8");
			Page pager = (Page) request.getAttribute("pager");			
			List<Book> subResult = (List<Book>) request.getAttribute("subResult");
			if (!subResult.isEmpty()) {
				for (int i = 0; i < subResult.size(); i++) {
					Book st = subResult.get(i);
					
			%>
			<tr > 
				<td><h4><%=st.getId()%></h4></td>
				<td><h4><%=st.getBookname() %></h4></td>
				<td><h4><%=st.getAuthor() %></h4></td>
				<td><h4><%=st.getPublishing() %></h4></td>
				<td><h4><%=st.getQuantity() %></h4></td>
				<td><h4><%=st.getPurchased() %></h4></td>
				<td><h4><%=(st.getBuytime()==null)?"无":st.getBuytime() %></h4></td>
				<td><h4><%=st.getPs()==null?"无":st.getPs() %></h4></td>
				
				<td><h4>
				 <a href="#">
          <span class="glyphicon glyphicon-pencil"
          onclick='document.form2.text1.value="<%=st.getId()%>";
				document.form2.text2.value="<%=st.getBookname()%>";
				document.form2.text3.value="<%=st.getAuthor()%>";
				document.form2.text4.value="<%=st.getPublishing()%>";
				document.form2.text5.value="<%=st.getQuantity()%>";
				
				document.form2.text7.value="<%=st.getBuytime()%>";
				document.form2.text8.value="<%=st.getPs()%>";' 
				class="btn btn-success" data-toggle="modal" data-target="#myModal2"></span>
        </a>
				
				<a href="doDelete.jsp?xh=<%=st.getId()%>">
				<span class="glyphicon glyphicon-trash"></span>
				</a></h4></td>
			</tr>
			<%
			
				}
			}
			%>
			
		</table>
		
		<div class="row clearfix">
				<div class="col-md-8 column">
				</div>
				<div class="col-md-4 column">
					<ul class="pagination pagination-lg" >
					<%
					int last = pager.getCurrentRecord() - pager.getPageSize();
					int next = pager.getCurrentRecord() + pager.getPageSize();
					int finalpage = (pager.getTotalPage()-1)*pager.getPageSize();
					int currentRecord;
					if (last >= 0) {						
						out.println("<li><a href='PageServlet?currentRecord="+0+"'>&laquo;</a></li>");
					} 
					if (last < 0) {						
					} else {
						out.print("<li><a href='PageServlet?currentRecord=" + last
								+ "'>&lsaquo;</a></li>");
					}
					if(pager.getCurrentPage()>0){
						for(int j=pager.getCurrentPage()-3;j<pager.getCurrentPage();j++){						
							if(j>=0){
								out.print("<li><a href='PageServlet?currentRecord=" + j*pager.getPageSize()
								+ "'>"+(j+1)+"</a></li>");
							}
						}
					}
					for(int i=pager.getCurrentPage();i<=pager.getCurrentPage()+3;i++){						
						
						if(i!=pager.getCurrentPage()){
							out.print("<li><a href='PageServlet?currentRecord=" + i*pager.getPageSize()
							+ "'>"+(i+1)+"</a></li>");
						}else
							
							out.print("<li class= 'active' ><a>"+(i+1)+"</a></li>");						
						if(i>=pager.getTotalPage()-1)
							break;
					}
					if (next >= pager.getTotalRecord()) {					
					} else {
						out.print("<li><a href='PageServlet?currentRecord=" + next
								+ "'>&rsaquo;</a></li>");
					}
					if (next < pager.getTotalRecord()) {
						out.println("<li><a href='PageServlet?currentRecord=" + finalpage
								+ "'>&raquo;</a></li>");
					}
					
				%>  
		</ul>
				</div>
			</div>
	
		
		
	</div>
	
	 <div class="container" style="margin-top:30px;">             
        <div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">添加书籍信息</h4>
              </div>
              <div class="modal-body">
              <form action="doinsert.jsp" method="post"  name="form1">
                <table class="table table-striped table-bordered table-hover table-condensed">		
		<tr><td>书名：</td><td><input type="text" name="Bookname" class="size2" id="txt2"></td></tr>
		<tr><td>作者：</td><td><input type="text" name="Author" class="size2" id="txt3"></td></tr>
		<tr><td>出版社：</td><td><input type="text" name="Publishing" class="size2" id="txt4"></td></tr>
		<tr><td>数量：</td><td><input type="text" name="Quantity" class="size2" id="txt5" onBlur="isNumber(this)"></td></tr>		 	
		<tr><td>是否已购买：</td><td>
			<input type="radio" name="Purchased" value="1" style="margin-left: 20px" onclick="changes1();" id="txt7" checked=""/>否
            <input type="radio" name="Purchased" value="2" style="margin-left: 20px" onclick="changes2();" id="txt7"/>是</td></tr>
		<tr><td>购买时间：</td><td><input style="display:none" id="test1" type='text' name="Buytime" style="width: 90%" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"   /></td></tr>
		<tr><td>备注：</td><td><input type="text" name="Ps" class="size2" id="txt8" ></td></tr>				
		</table>		
              </div>
              <div class="modal-footer">
             	<input type="submit" value="加入" class="btn btn-default" >
				<input type="reset" value="重置" class="btn btn-default">                
              </div>
              </form>
            </div>
          </div>
        </div>
	
	
 <div class="container" style="margin-top:30px;">             
        <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
          <div class="modal-dialog" role="document">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">更新书籍信息</h4>
              </div>
              <div class="modal-body">
              <form action="doUpdate.jsp" method="post" name="form2">
                <table class="table table-striped table-bordered table-hover table-condensed">		
		<tr><td>编号：</td><td><input type="text" name="Id" class="size2" id="text1" readonly ></td></tr>
		<tr><td>书名：</td><td><input type="text" name="Bookname" class="size2" id="text2"></td></tr>
		<tr><td>作者：</td><td><input type="text" name="Author" class="size2" id="text3"></td></tr>
		<tr><td>出版社：</td><td><input type="text" name="Publishing" class="size2" id="text4"></td></tr>
		<tr><td>数量：</td><td><input type="text" name="Quantity" class="size2" id="text5" onBlur="isNumber2(this)"></td></tr>		 					
		<tr><td>是否已购买：</td><td>
			<input type="radio" name="Purchased" value="1" style="margin-left: 20px" onclick="changes3();" id="text6" checked=""/>否
            <input type="radio" name="Purchased" value="2" style="margin-left: 20px" onclick="changes4();" id="text6" />是</td></tr>
		<tr><td>购买时间：</td><td><input style="display:none" id="text7" type='text' name="Buytime" style="width: 90%" class="Wdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"   /></td></tr>
		<tr><td>备注：</td><td><input type="text" name="Ps" class="size2" id="text8" ></td></tr>		
		</table>		
              </div>
              <div class="modal-footer">
            	<input type="submit" value="修改" class="btn btn-default">
				<input type="reset" value="重置" class="btn btn-default">            	            
              </div>
              </form>
            </div>
          </div>
        </div>





<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>    

</body>
</html>